library(pacman)
p_load(rvest, stringr, tidyverse)

#link with list of parliament members
link <- "https://www.ft.dk/da/medlemmer/medlemmernes-adresser"

#Scraping link
web <- read_html(link)
members <- html_nodes(web,"td > a")
members <- html_text(members)
members <- data.frame(name=as.character(unlist(members)))
members$name <- as.character(members$name)

#making columns with name and party
members$party <- str_remove_all(str_extract(members$name, "\\([a-zA-z]."), "[:punct:]")
members$name <- substr(str_remove(members$name, "\\(.*"),1,nchar(str_remove(members$name, "\\(.*"))-1)

#Great stuff
members[1:10,]
##                           name party
## 1             Mette Abildgaard    KF
## 2                Karina Adsbøl    DF
## 3                 Tommy Ahlers     V
## 4              Alex Ahrendtsen    DF
## 5       Marlene Ambo-Rasmussen     V
## 6          Katarina Ammitzbøll    KF
## 7  Simon Emil Ammitzbøll-Bille    UF
## 8                Hans Andersen     V
## 9     Kirsten Normann Andersen    SF
## 10                   Ida Auken    RV

Setting up twitter scraper

p_load(twitteR,httr)
oauth_endpoint(authorize = "https://api.twitter.com/oauth",
               access = "https://api.twitter.com/oauth/access_token")
## <oauth_endpoint>
##  authorize: https://api.twitter.com/oauth
##  access:    https://api.twitter.com/oauth/access_token
consumer_key <- "J9SE1V1V94POa67f1lYMcU1Li"
consumer_secret <- "2dSwlY5p0oddQ5eC0UKAYgIwLaThV5acpOCLCaX1poWjJ9xyo6"
access_token <- "3184351755-eVNLDY2dRGOhvi5jKqHdmswrqiBmm09eLwo41C9"
access_secret <- "GLZR7ZtKZ8GMEPqzhB5uH3Vymmth5p5Z5DAkVOS3wieXv"
twitteR::setup_twitter_oauth(consumer_key,consumer_secret,access_token,access_secret)
## [1] "Using direct authentication"

Scraping twitter for all the parliament members

#Loading packages
p_load(gtools, lubridate)

#Creating empty dataframe i can bind the tweets to
all <- as.data.frame(matrix(0))

#Searching twitter for the parliament members one at a time, saving the tweets in the dataframe
for(i in 1:nrow(members)){
  print(i)
  df <- searchTwitter(members$name[i], n=5000, lang="da")
  if(length(df)!=0){
    df <- twListToDF(df)
    df$name <- members$name[i]
    df$party <- members$party[i]
    all <- smartbind(all,df)
  }
}
## [1] 1
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 3
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## [1] 2
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 3
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 13
## Warning in smartbind(all, df): Column class mismatch for 'replyToSN'. Converting
## column to class 'character'.
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## Warning in smartbind(all, df): Column class mismatch for 'replyToSID'.
## Converting column to class 'character'.
## Warning in smartbind(all, df): Column class mismatch for 'replyToUID'.
## Converting column to class 'character'.
## [1] 4
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 5
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## [1] 6
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 7
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 2

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 8
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 51

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 9
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 10
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 11
## [1] "Rate limited .... blocking for a minute and retrying up to 119 times ..."
## [1] "Rate limited .... blocking for a minute and retrying up to 118 times ..."
## [1] "Rate limited .... blocking for a minute and retrying up to 117 times ..."
## [1] "Rate limited .... blocking for a minute and retrying up to 116 times ..."
## [1] "Rate limited .... blocking for a minute and retrying up to 115 times ..."
## [1] "Rate limited .... blocking for a minute and retrying up to 114 times ..."
## [1] "Rate limited .... blocking for a minute and retrying up to 113 times ..."
## [1] "Rate limited .... blocking for a minute and retrying up to 112 times ..."
## [1] "Rate limited .... blocking for a minute and retrying up to 111 times ..."
## [1] "Rate limited .... blocking for a minute and retrying up to 110 times ..."
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 12
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 13
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 14
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 15
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 16
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 17
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 104

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 18
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 19
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1
## Warning in smartbind(all, df): Column class mismatch for 'replyToSN'. Converting
## column to class 'character'.
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## Warning in smartbind(all, df): Column class mismatch for 'replyToSID'.
## Converting column to class 'character'.
## Warning in smartbind(all, df): Column class mismatch for 'replyToUID'.
## Converting column to class 'character'.
## [1] 20
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 40
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## [1] 21
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 22
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 2

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 23
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 14

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 24
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 25
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 26
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 27
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 2
## Warning in smartbind(all, df): Column class mismatch for 'replyToSN'. Converting
## column to class 'character'.
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## Warning in smartbind(all, df): Column class mismatch for 'replyToSID'.
## Converting column to class 'character'.
## Warning in smartbind(all, df): Column class mismatch for 'replyToUID'.
## Converting column to class 'character'.
## [1] 28
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 55
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## [1] 29
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 30
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 4

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 31
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 7

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 32
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 33
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 34
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1
## Warning in smartbind(all, df): Column class mismatch for 'replyToSN'. Converting
## column to class 'character'.
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## Warning in smartbind(all, df): Column class mismatch for 'replyToSID'.
## Converting column to class 'character'.
## Warning in smartbind(all, df): Column class mismatch for 'replyToUID'.
## Converting column to class 'character'.
## [1] 35
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## [1] 36
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 37
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 5

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 38
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 8

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 39
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1
## Warning in smartbind(all, df): Column class mismatch for 'replyToSN'. Converting
## column to class 'character'.
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## Warning in smartbind(all, df): Column class mismatch for 'replyToSID'.
## Converting column to class 'character'.
## Warning in smartbind(all, df): Column class mismatch for 'replyToUID'.
## Converting column to class 'character'.
## [1] 40
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 3
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## [1] 41
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 17

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 42
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 13
## Warning in smartbind(all, df): Column class mismatch for 'replyToSN'. Converting
## column to class 'character'.
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## Warning in smartbind(all, df): Column class mismatch for 'replyToSID'.
## Converting column to class 'character'.
## Warning in smartbind(all, df): Column class mismatch for 'replyToUID'.
## Converting column to class 'character'.
## [1] 43
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 15
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## [1] 44
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 45
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 7

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 46
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 7
## Warning in smartbind(all, df): Column class mismatch for 'replyToSN'. Converting
## column to class 'character'.
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## Warning in smartbind(all, df): Column class mismatch for 'replyToSID'.
## Converting column to class 'character'.
## Warning in smartbind(all, df): Column class mismatch for 'replyToUID'.
## Converting column to class 'character'.
## [1] 47
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 3
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## [1] 48
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 692

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 49
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 50
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 242

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 51
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 3

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 52
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 53
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 54
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 2

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 55
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 2

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 56
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 57
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 58
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 8

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 59
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 60
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 61
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 102

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 62
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 63
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 64
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 7

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 65
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 2

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 66
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 4
## Warning in smartbind(all, df): Column class mismatch for 'replyToSN'. Converting
## column to class 'character'.
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## Warning in smartbind(all, df): Column class mismatch for 'replyToSID'.
## Converting column to class 'character'.
## Warning in smartbind(all, df): Column class mismatch for 'replyToUID'.
## Converting column to class 'character'.
## [1] 67
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 7
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## [1] 68
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 69
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 70
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 19

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 71
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 72
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 13

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 73
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 3
## Warning in smartbind(all, df): Column class mismatch for 'replyToSN'. Converting
## column to class 'character'.
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## Warning in smartbind(all, df): Column class mismatch for 'replyToSID'.
## Converting column to class 'character'.
## Warning in smartbind(all, df): Column class mismatch for 'replyToUID'.
## Converting column to class 'character'.
## [1] 74
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 12
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## [1] 75
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 96

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 76
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 77
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 78
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 45

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 79
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 21

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 80
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 43

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 81
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 82
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 5

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 83
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 84
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 85
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 11

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 86
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 56

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 87
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 11

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 88
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 189

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 89
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 90
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 5
## Warning in smartbind(all, df): Column class mismatch for 'replyToSN'. Converting
## column to class 'character'.
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## Warning in smartbind(all, df): Column class mismatch for 'replyToSID'.
## Converting column to class 'character'.
## Warning in smartbind(all, df): Column class mismatch for 'replyToUID'.
## Converting column to class 'character'.
## [1] 91
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 92
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 593
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## [1] 93
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 94
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 3

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 95
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 16

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 96
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 12

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 97
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 14

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 98
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 2

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 99
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 100
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1
## Warning in smartbind(all, df): Column class mismatch for 'replyToSN'. Converting
## column to class 'character'.
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## Warning in smartbind(all, df): Column class mismatch for 'replyToSID'.
## Converting column to class 'character'.
## Warning in smartbind(all, df): Column class mismatch for 'replyToUID'.
## Converting column to class 'character'.
## [1] 101
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## [1] 102
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 103
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 3

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 104
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1
## Warning in smartbind(all, df): Column class mismatch for 'replyToSN'. Converting
## column to class 'character'.
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## Warning in smartbind(all, df): Column class mismatch for 'replyToSID'.
## Converting column to class 'character'.
## Warning in smartbind(all, df): Column class mismatch for 'replyToUID'.
## Converting column to class 'character'.
## [1] 105
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## [1] 106
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 71

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 107
## [1] "Rate limited .... blocking for a minute and retrying up to 119 times ..."
## [1] "Rate limited .... blocking for a minute and retrying up to 118 times ..."
## [1] "Rate limited .... blocking for a minute and retrying up to 117 times ..."
## [1] "Rate limited .... blocking for a minute and retrying up to 116 times ..."
## [1] "Rate limited .... blocking for a minute and retrying up to 115 times ..."
## [1] "Rate limited .... blocking for a minute and retrying up to 114 times ..."
## [1] "Rate limited .... blocking for a minute and retrying up to 113 times ..."
## [1] "Rate limited .... blocking for a minute and retrying up to 112 times ..."
## [1] "Rate limited .... blocking for a minute and retrying up to 111 times ..."
## [1] "Rate limited .... blocking for a minute and retrying up to 110 times ..."
## [1] "Rate limited .... blocking for a minute and retrying up to 109 times ..."
## [1] "Rate limited .... blocking for a minute and retrying up to 108 times ..."
## [1] "Rate limited .... blocking for a minute and retrying up to 107 times ..."
## [1] "Rate limited .... blocking for a minute and retrying up to 106 times ..."
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 2
## Warning in smartbind(all, df): Column class mismatch for 'replyToSN'. Converting
## column to class 'character'.
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## Warning in smartbind(all, df): Column class mismatch for 'replyToSID'.
## Converting column to class 'character'.
## Warning in smartbind(all, df): Column class mismatch for 'replyToUID'.
## Converting column to class 'character'.
## [1] 108
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 11
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## [1] 109
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 3
## Warning in smartbind(all, df): Column class mismatch for 'replyToSN'. Converting
## column to class 'character'.
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## Warning in smartbind(all, df): Column class mismatch for 'replyToSID'.
## Converting column to class 'character'.
## Warning in smartbind(all, df): Column class mismatch for 'replyToUID'.
## Converting column to class 'character'.
## [1] 110
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 11
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## [1] 111
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 8

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 112
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 113
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 10

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 114
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 14

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 115
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 5

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 116
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 117
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 4

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 118
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 6

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 119
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 120
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 121
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 3

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 122
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 28

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 123
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 124
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 353

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 125
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 126
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 3

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 127
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 3
## Warning in smartbind(all, df): Column class mismatch for 'replyToSN'. Converting
## column to class 'character'.
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## Warning in smartbind(all, df): Column class mismatch for 'replyToSID'.
## Converting column to class 'character'.
## Warning in smartbind(all, df): Column class mismatch for 'replyToUID'.
## Converting column to class 'character'.
## [1] 128
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 66
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## [1] 129
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 130
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 8

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 131
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 3

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 132
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 6
## Warning in smartbind(all, df): Column class mismatch for 'replyToSN'. Converting
## column to class 'character'.
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## Warning in smartbind(all, df): Column class mismatch for 'replyToSID'.
## Converting column to class 'character'.
## Warning in smartbind(all, df): Column class mismatch for 'replyToUID'.
## Converting column to class 'character'.
## [1] 133
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 134
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 49
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## [1] 135
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 136
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 33

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 137
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 138
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 139
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 8
## Warning in smartbind(all, df): Column class mismatch for 'replyToSN'. Converting
## column to class 'character'.
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## Warning in smartbind(all, df): Column class mismatch for 'replyToSID'.
## Converting column to class 'character'.
## Warning in smartbind(all, df): Column class mismatch for 'replyToUID'.
## Converting column to class 'character'.
## [1] 140
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 8
## Warning in smartbind(all, df): Column class mismatch for 'replyToSN'. Converting
## column to class 'character'.
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## Warning in smartbind(all, df): Column class mismatch for 'replyToSID'.
## Converting column to class 'character'.
## Warning in smartbind(all, df): Column class mismatch for 'replyToUID'.
## Converting column to class 'character'.
## [1] 141
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1
## Warning in smartbind(all, df): Column class mismatch for 'replyToSN'. Converting
## column to class 'character'.
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## Warning in smartbind(all, df): Column class mismatch for 'replyToSID'.
## Converting column to class 'character'.
## Warning in smartbind(all, df): Column class mismatch for 'replyToUID'.
## Converting column to class 'character'.
## [1] 142
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 11
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## [1] 143
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 144
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 145
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 146
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 4

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 147
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 241

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 148
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 16

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 149
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 150
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 151
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 2

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 152
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 12

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 153
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 154
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 15

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 155
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 156
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 157
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 44

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 158
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 4

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 159
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 26

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 160
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 23

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 161
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 2

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 162
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 215

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 163
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 164
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 9
## Warning in smartbind(all, df): Column class mismatch for 'replyToSN'. Converting
## column to class 'character'.
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## Warning in smartbind(all, df): Column class mismatch for 'replyToSID'.
## Converting column to class 'character'.
## Warning in smartbind(all, df): Column class mismatch for 'replyToUID'.
## Converting column to class 'character'.
## [1] 165
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 13
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## [1] 166
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 24

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 167
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 168
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1
## Warning in smartbind(all, df): Column class mismatch for 'replyToSN'. Converting
## column to class 'character'.
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## Warning in smartbind(all, df): Column class mismatch for 'replyToSID'.
## Converting column to class 'character'.
## Warning in smartbind(all, df): Column class mismatch for 'replyToUID'.
## Converting column to class 'character'.
## [1] 169
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 331
## Warning in smartbind(all, df): Converting non-atomic type column 'created' to
## type character.
## [1] 170
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 2

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 171
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 3

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 172
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 173
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 135

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 174
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 175
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 1

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 176
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 12

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 177
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 3

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 178
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 164

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 179
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 0
## [1] 180
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 3

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
## [1] 181
## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit =
## retryOnRateLimit, : 5000 tweets were requested but the API can only return 61

## Warning in doRppAPICall("search/tweets", n, params = params, retryOnRateLimit
## = retryOnRateLimit, : Converting non-atomic type column 'created' to type
## character.
folketinget_df <- all[-1,-1]
rownames(folketinget_df) <- 1:nrow(folketinget_df)
#loading tweets i scraped last week, and adding the new ones
folketinget_df_1 <- read.csv("folketinget_twitter.csv")

folketinget_df <- rbind(folketinget_df_1, folketinget_df)
folketinget_df <- folketinget_df[!duplicated(folketinget_df$id),]
folketinget_df %>% group_by(name, ) %>% summarise(n=n()) %>% arrange(desc(n))
## `summarise()` ungrouping output (override with `.groups` argument)
## # A tibble: 130 x 2
##    name                  n
##    <fct>             <int>
##  1 Mette Frederiksen  1532
##  2 Pia Kjærsgaard      994
##  3 Signe Munk          519
##  4 Carl Valentin       461
##  5 Martin Geertsen     429
##  6 Jens Rohde          343
##  7 Inger Støjberg      309
##  8 Jesper Petersen     255
##  9 Susanne Zimmer      255
## 10 Naser Khader        213
## # … with 120 more rows
folketinget_df$created <- as.Date(folketinget_df$created)
folketinget_df$created <- ymd(folketinget_df$created)

tops <- as.data.frame(matrix(0,ncol=4))
names(tops) <- c("name", "n","date", "rank")
for(l in levels(as.factor(folketinget_df$created))){
  since <- folketinget_df[folketinget_df$created<=l,]
  top10 <- since %>% group_by(name) %>% summarise(n=n()) %>%
    arrange(desc(n)) %>% top_n(10)
  top10 <- top10[1:10,]
  top10$date <- l
  top10$rank <- 1:10
  tops <- rbind(tops,top10)
}
## `summarise()` ungrouping output (override with `.groups` argument)
## Selecting by n
## `summarise()` ungrouping output (override with `.groups` argument)
## Selecting by n
## `summarise()` ungrouping output (override with `.groups` argument)
## Selecting by n
## `summarise()` ungrouping output (override with `.groups` argument)
## Selecting by n
## `summarise()` ungrouping output (override with `.groups` argument)
## Selecting by n
## `summarise()` ungrouping output (override with `.groups` argument)
## Selecting by n
## `summarise()` ungrouping output (override with `.groups` argument)
## Selecting by n
## `summarise()` ungrouping output (override with `.groups` argument)
## Selecting by n
## `summarise()` ungrouping output (override with `.groups` argument)
## Selecting by n
## `summarise()` ungrouping output (override with `.groups` argument)
## Selecting by n
## `summarise()` ungrouping output (override with `.groups` argument)
## Selecting by n
## `summarise()` ungrouping output (override with `.groups` argument)
## Selecting by n
## `summarise()` ungrouping output (override with `.groups` argument)
## Selecting by n
## `summarise()` ungrouping output (override with `.groups` argument)
## Selecting by n
tops <- tops[-1,]
tops <- left_join(tops, members)
## Joining, by = "name"

Making bar chart race, to explore the most mentioned members of the Danish parliament

p_load(scales,gganimate,ggplot2)
tops$party <- as.factor(tops$party)

#I used the chrome addon colorzilla to grab the color codes from the parties' websites
party_colours <- c("#024D89", "#00593C","#281815", "#EC008C", "#F04D46","#C4171B", "#03BA50", "#002883")
p <- tops %>%
    ggplot(aes(x = -rank,y = n)) +
        geom_tile(aes(y = n/2, height = n, fill = party), width = 0.9) +
        geom_text(aes(label = name), hjust = "right", colour = "#bebebe", fontface = "bold", nudge_y = -10) +
        geom_text(aes(label = scales::comma(n, scale=1,accuracy = 1)),hjust = "left", nudge_y = 10, colour = "grey30") +
        coord_flip(clip="off") +
        scale_fill_manual(name = 'Party', 
                          values = party_colours,
                          aesthetics = "fill") +
        scale_x_discrete("") +
        scale_y_continuous("",labels=scales::comma) +
        theme(panel.grid.major.y=element_blank(),
              panel.grid.minor.x=element_blank(),
              plot.margin = margin(1,1,1,2,"cm"),
              axis.text.y=element_blank()) +
        # gganimate code to transition by year:
        transition_time(ymd(date)) +
        labs(title='Most mentioned parliament members on Twitter.com in the last 14 days',
             subtitle='Mentions at {round(frame_time,0)}',
             caption='Source: twitter.com')

animate(p, nframes = 600, fps = 25, end_pause = 50, width = 1200, height = 900)